package com.lzy.permission.entity;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="tb_user")
public class User {
	
	@Id
	@Column(length=32)
	private String id ;

	@Column(length=64,nullable=false)
	private String username ;
	
	@Column(length=64,nullable=false)
	private String password ;
	
	@Column
	private int status ;

	@OneToMany(fetch=FetchType.LAZY)
	@JoinTable(name="tb_user_role",joinColumns={@JoinColumn(name="user_id")},
			   inverseJoinColumns={@JoinColumn(name="role_id")} )
	private Set<Role> roles = new HashSet<Role>();
	
	public Set<Role> getUserRoles() {
		return roles;
	}

	public void setUserRoles(Set<Role> roles) {
		this.roles = roles;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	} 
	
}
